/**
 * 通用JavaScript方法 
 */

/**
 * 闭包处理页面加载效果
 */
var url = location.href;

function getRootPath() {
	var strFullPath = window.document.location.href;
	var strPath = window.document.location.pathname;
	var pos = strFullPath.indexOf(strPath);
	var prePath = strFullPath.substring(0, pos);
	return (prePath + contextPath);
}

function closePopWindown() {
	var api = frameElement.api;
	api.close();
}

function refreshWindow() {
	var api = frameElement.api, W = api.opener;
	W.location.reload();
}
function refresh() {
	location.reload();
}

function confirmDelete(msg) {
	$.dialog.confirm(msg, function() {
		return true;
	}, function() {
		return false;
	});
}

function showMessage(info) {
	$.dialog({
		id : 'msg',
		title : '提示信息',
		content : info,
		width : 200,
		height : 100,
		left : '100%',
		top : '100%',
		fixed : true,
		drag : false,
		resize : false,
		time : 5,
		lock : true,
		max : false,
		min : false
	});
}
function cutDay(days) {
	var date = new Date();
	return new Date(date.getTime() - days * 1000 * 24 * 60 * 60);
}

function formatDate(date, env) {
	var year = date.getFullYear();
	var month = date.getMonth() + 1;
	var day = date.getDate();
	switch (env) {
	case 1:
		return year + '-' + (month < 10 ? "0" + month : month) + '-' + (day < 10 ? "0" + day : day);
	case 2:
		return year + '-' + (month < 10 ? "0" + month : month);
	case 3:
		return year + '';
	}
}
/**
 * 注销
 */
function logout() {
	$.post(getRootPath() + "/logout.ac", {}, function(result) {
		if (result.operationState == "SUCCESS") {
			location.href = getRootPath();
		} else {
			showMessage("执行注销失败<br>请直接关闭浏览器退出");
		}
	}, "json");
}
$(function() {
	//禁用分页条的disabled节点
	$('.pagination .disabled a').on('click', function() {
		return false;
	});
});
